package cosc617_blackteam;

import java.util.ArrayList;

/**
 * @author Laura
 * An iterator that iterates through all Orders
 */
public class DefaultOrderIterator implements I_OrderIterator {

	private ArrayList<Order> orders;
	private int index;
	
	public DefaultOrderIterator(ArrayList<Order> orders){
		this.orders = orders;
		index = 0;
	}
	@Override
	public boolean hasNext() {
		return index < orders.size();
	}

	@Override
	public Order next() {
		Order output = null;
		if(hasNext()){
		 output = orders.get(index);
		 index++;
		}
		return output;
		
	}

	@Override
	public void remove() {
		orders.remove(index - 1); //because we incremented already we need to do index -1

	}

}
